package com.novoda.runbuddy.view;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.novoda.runbuddy.activity.stopwatch.StopwatchTools;
import com.novoda.runbuddy.controller.IDayController;
import com.novoda.runbuddy.controller.IRouteRunnerController;
import com.novoda.runbuddy.controller.RouteRunnerControllerImpl;
import com.novoda.runbuddy.model.Run;
import com.novoda.runbuddy.model.ListOfRuns;
import com.novoda.runbuddy.model.Route;

public class RouteListAdapter extends BaseAdapter {

	private List<Route>		routes;
	private final Activity	activity;
	private IRouteRunnerController	dayOfJogDetailsController;

	public RouteListAdapter(Activity routeRunner, List<Route> allRoutesAroundCurrentArea, RouteRunnerControllerImpl routeRunnerControllerImpl) {
		this.activity = routeRunner;
		this.routes = allRoutesAroundCurrentArea;
		this.dayOfJogDetailsController = routeRunnerControllerImpl;
	}

	public int getCount() {
		return this.routes.size();
	}

	public Route getItem(int position) {
		return this.routes.get(position);
	}

	public long getItemId(int position) {
		return this.routes.get(position)._id;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		TextView miles;
		TextView jogname;
		TextView timerun;

		miles = new TextView(activity);
		miles.setText("00");

		jogname = new TextView(activity);
		jogname.setText(routes.get(position).name);

//		timerun = new TextView(activity);
//		timerun.setText(StopwatchTools.getFormattedDiff(routes.get(position).getStartTime(), routes.get(position)
//				.getStopTime()));

		RouteEntryView todayView = new RouteEntryView(activity, routes.get(position).name, dayOfJogDetailsController);
		return todayView;
	}
	
}
